package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查看套餐
     * @param setmeal
     * @return
     */
    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> selectByCatId(Setmeal setmeal);

    /**
     * 根据分类id查询套餐
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<DishItemVO> selectBySetmealId(@Param("id") Long id);

    /**
     * 套餐分页查询
     * @param setmeal
     * @return
     */
    @Select("select * from setmeal")
    List<Setmeal> pageFind(Setmeal setmeal);

    /**
     * 根据id查询套餐
     * @param setmeal
     * @return
     */
    @Select("select * from setmeal where id = #{id}")
    Setmeal selectById(Setmeal setmeal);

    /**
     * 添加套餐数据
     * @param setmeal
     */
    @AutoFill(OperationType.INSERT)
    void insert(Setmeal setmeal);

    /**
     * 修改套餐
     * @param setmeal
     */
    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    /**
     * 根据id删除套餐
     * @param ids
     */
    void deleteSet(List<Long> ids);

    /**
     * 根据订餐状态进行统计
     * @param setmeal
     * @return
     */
    @Select("select count(status) from setmeal where status = #{status}")
    Integer overviewSetmealsAmount(Setmeal setmeal);

}
